package com.simcult;


import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class MainMenu extends ListActivity {

	private static String[] menuItems;
	private static int MENU_ITEM_KEY_INDEX_EXIT = 3;
	private static int MENU_ITEM_KEY_INDEX_NEW_GAME = 0;
	
	
	
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        menuItems = getResources().getStringArray(R.array.main_menu_button_names);
        
        setListAdapter(new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_multiple_choice,menuItems));
        
        final ListView listView = getListView();
        
        listView.setItemsCanFocus(false);
        listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        listView.setBackgroundResource(R.drawable.bgsplashtile);

    }    
    
    
    @Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
    	
			
	    
    	
    		if(position==MENU_ITEM_KEY_INDEX_EXIT){
    			Toast.makeText(this,getResources().getString(R.string.exiting_message),Toast.LENGTH_SHORT).show();
    			//TODO shut down other activities associated with this?
    			finish();
    		}else if(position==MENU_ITEM_KEY_INDEX_NEW_GAME){
    			startActivity(new Intent("com.simcult.PlayGame"));
    			finish();
    		}
    	
    		
    	
		
	}
}